<h2> Liste des factures</h2>

<table id="t_facture" >
	<thead>
    	<tr>
    		<th> ID </th>
            <th> Client </th>
            <th> Date </th>
            <th> Montant TTC </th>
    		<th></th>
    	</tr>
    </thead>
	<?foreach($factures as $facture){
	?>
        <tr>
        	<td><?=$facture->_id?></td>
            <td><?=$aContacts[$facture->_fournisseur]?></td>
            <td><?=date("d-m-Y",strtotime($facture->date))?></td>
            <td><?=$facture->montant_ttc?> &euro;</td>
            <td> 
            	<?if(!isset($aPaiementsFournisseur[$facture->_id])){?>
            		<a href="javascript:removeFactureFournisseur('<?=$facture->_id?>');"><img src="/public/images/icons/remove.png" title="Supprimer la facture"/></a>
            		<a href="javascript:editFactureFournisseur('<?=$facture->_id?>');"><img src="/public/images/icons/edit.png" title="Modifier la facture"/></a>
            		<a href="javascript:enregistrerPaiementFournisseur('<?=$facture->_id?>');"><img src="/public/images/icons/dollar.png" title="Enregistrer le paiement"/></a>
            		
            	<?}else{?>
            		<a href="javascript:previewFacture('<?=$facture->_id?>');"><img src="/public/images/icons/preview.png" title="Apreçu"/></a>
            	<?}?> 
            </td>
    	</tr>
	<?}?>
</table>

<br/>
<center>
	<button onclick="$('#new_facture_dial').dialog('open');" id="bouttonNew"> Nouvelle facture </button>
</center>
<div id="new_facture_dial">
	<?=$this->inc("achats/form_facture",array("aContacts"=>$aContacts,"typesReglements"=>$typesReglements,"aTVA"=>$aTVA,"planComptable"=>$planComptable));?>
</div>
<?if(isset($_GET["fournisseur_id"])){?>
<script>
$(document).ready(function() {
	$("#contact_<?=$_GET["fournisseur_id"]?>").attr("checked",true);
	$( "#creer_facture_tabs" ).tabs("select", 1 );
	$('#new_facture_dial').dialog('open');
});
</script>
<?}?>